<?php

namespace app\adminmall\model;
use think\Model;
use think\Db;

class SiteModel extends Model
{
    protected $name = 'mall_setting';
    
    // 开启自动写入时间戳
    protected $autoWriteTimestamp = false;
	/**
	 * 新增和保存
	 * @author lx
	 */
	function setting_save($data, $key,$inc_type) {
		if (empty($key)) {
			return FALSE;
		}
		$record = array();
		$record['value'] = iserializer($data);
		$record['inc_type'] =$inc_type;
		$exists =$this->where("key",$key)->find();
		if ($exists) {
			$where['key']=$key;
			$return = $this->where($where)->update($record);
		} else {
			$record['key'] = $key;
			$return = $this->allowField(true)->save($record);
		}		
	return $return;
}
	
}